.TH std::expected::value 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::expected::value \- std::expected::value

.SH Synopsis
   T is not (possibly cv-qualified) void
   constexpr T& value() &;               \fB(1)\fP (since C++23)
   constexpr const T& value() const&;    \fB(2)\fP (since C++23)
   constexpr T&& value() &&;             \fB(3)\fP (since C++23)
   constexpr const T&& value() const&&;  \fB(4)\fP (since C++23)
   T is (possibly cv-qualified) void
   constexpr void value() const&;        \fB(5)\fP (since C++23)
   constexpr void value() &&;            \fB(6)\fP (since C++23)

   If *this contains an expected value, returns a reference to the contained value.
   Returns nothing if T is (possibly cv-qualified) void.

   Otherwise, throws an exception of type std::bad_expected_access<std::decay_t<E>>
   that contains a copy of error().

   1,2) If std::is_copy_constructible_v<E> is false, the program is ill-formed.
   3,4) If std::is_copy_constructible_v<E> or std::is_constructible_v<E,
   decltype(std::move(error()))> is false, the program is ill-formed.
   5) If std::is_copy_constructible_v<E> is false, the program is ill-formed.
   6) If std::is_move_constructible_v<E> is false, the program is ill-formed.

.SH Parameters

   \fI(none)\fP

.SH Return value

   1-4) The expected value contained in *this.
   5,6) \fI(none)\fP

.SH Exceptions

   1,2,5) Throws std::bad_expected_access(std::as_const(error())) if *this contains an
   unexpected value.
   3,4,6) Throws std::bad_expected_access(std::move(error())) if *this contains an
   unexpected value.

.SH Example

    This section is incomplete
    Reason: no example

   Defect reports

   The following behavior-changing defect reports were applied retroactively to
   previously published C++ standards.

      DR    Applied to              Behavior as published              Correct behavior
   LWG 3940 C++23      E was not required to be                        required
                       copy/move-constructible for overloads (5,6)

.SH See also

   value_or            returns the expected value if present, another value otherwise
                       \fI(public member function)\fP
   operator->          accesses the expected value
   operator*           \fI(public member function)\fP
   error               returns the unexpected value
                       \fI(public member function)\fP
   bad_expected_access exception indicating checked access to an expected that contains
   (C++23)             an unexpected value
                       \fI(class template)\fP

.SH Category:
     * Todo no example
